package cn.fbs.controller.core;

import cn.fbs.param.DataParam;
import cn.fbs.param.ImageParam;
import cn.fbs.param.VideoParam;
import cn.fbs.service.core.ReviewService;
import cn.fbs.vo.DataEvaluateVo;
import cn.fbs.vo.ImageEvaluateVo;
import cn.fbs.vo.VideoEvaluateVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

import static cn.fbs.util.RequestUtils.getUserId;

@RestController
public class ReviewController {

    @Autowired
    private ReviewService reviewService;

    @ApiOperation("审核ZC图像")
    @PostMapping("imageData/examineZCImage")
    public String examineZCImage(@RequestBody ImageParam uploadParam, HttpServletRequest request) throws Exception {
        uploadParam.setUserId(getUserId(request));
        return reviewService.examineZCImage(uploadParam);
    }


    @ApiOperation("临时会审")
    @GetMapping("imageData/tempExamine")
    public String tempExamine(@RequestParam int fileType,@RequestParam long id,@RequestParam int examineType){
        try{
            reviewService.tempExamine(fileType,examineType,id);
        }catch (Exception e){
            e.printStackTrace();
            return "500,"+e.getMessage();
        }

        return "200,操作成功";
    }

    @ApiOperation("审核ZC视频")
    @PostMapping("imageData/examineZCVideo")
    public String examineZCVideo(@RequestBody VideoParam uploadParam, HttpServletRequest request) throws Exception {

        uploadParam.setUserId(getUserId(request));
        return reviewService.examineZCVideo(uploadParam);
    }

    @ApiOperation("审核资料文档")
    @PostMapping("imageData/examineDataInfo")
    public String examineDataInfo(@RequestBody DataParam uploadParam, HttpServletRequest request) throws Exception {

        uploadParam.setUserId(getUserId(request));
        return reviewService.examineDataInfo(uploadParam);
    }

    @ApiOperation("资料评价详情")
    @GetMapping("imageData/dataEvaluate")
    @ApiImplicitParam(name = "id", value = "文档ID")
    public DataEvaluateVo getDataEvaluate(@RequestParam("id") Long id) {
        return reviewService.getDataEvaluate(id);
    }

    @ApiOperation("视频评价详情")
    @GetMapping("imageData/videoEvaluate")
    @ApiImplicitParam(name = "id", value = "视频ID")
    public VideoEvaluateVo getVideoEvaluate(@RequestParam("id") Long id) {
        return reviewService.getVideoEvaluate(id);
    }

    @ApiOperation("图像评价详情")
    @GetMapping("imageData/imageEvaluate")
    @ApiImplicitParam(name = "id", value = "图像ID")
    public ImageEvaluateVo getImageEvaluate(@RequestParam("id") Long id) {
        return reviewService.getImageEvaluate(id);
    }


}
